﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;

public class Player : MonoBehaviour
{
    public static Player Instance;
    public UnityEvent<Collider> onFootTriggerEnter = new UnityEvent<Collider>();
    public UnityEvent<Collider> onBodyCollisionEnter = new UnityEvent<Collider>();
    private Collider lastCollider;

    private void Awake()
    {
        Instance = this;
    }

    public void FootTriggerEnter(Collider other) 
    {
        onFootTriggerEnter?.Invoke(other);
    }

    private void OnControllerColliderHit(ControllerColliderHit hit)
    {
        if (lastCollider != hit.collider)
        {
            onBodyCollisionEnter?.Invoke(hit.collider);
            lastCollider = hit.collider;
        }
    }
}
